版权声明:本文为博主原创文章,转载请注明出处:http://blog.jerkybible.com/2013/11/19/2013-11-19-CODE 6 Word Ladder II/
访问原文「CODE 6. Word Ladder II」
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:
- Only one letter can be changed at a time
- Each intermediate word must exist in the dictionary
For example,
Given:
start = "hit"
end = "cog"
dict = ["hot","dot","dog","lot","log"]
Return
[
["hit","hot","dot","dog","cog"],
["hit","hot","lot","log","cog"]
]
Note:
- All words have the same length.
- All words contain only lowercase alphabetic characters.
|
|